<html>
<head>
<title>后台管理</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>public/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>public/css/bootstrap-theme.min.css">
<script type="text/javascript" src="<?php echo base_url();?>public/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>public/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>public/kindeditor/kindeditor-all-min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>public/kindeditor/lang/zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>public/css/style.css">
</head>
<body>
<?php $this->load->view('admin/admin_nav'); ?>
<div class="container">
	<h3>文章<small>列表</small><a class="pull-right btn btn-success btn-sm add" href="<?php echo site_url('admin/article/add') ?>">添加</a></h3>
	<table class="table table-striped table-bordered " cellpadding="0" cellspacing="0" >
		<tr>
			<th>标题</th>
			<th>创建时间</th>
			<th>访问人数</th>
			<th>是否推荐</th>
			<th>操作</th>
		</tr>
		<?php if(empty($articles)) {?>
			<tr>
				<td colspan="9" class="empty">没有数据</td>
			</tr>
		<?php
			}
			foreach ($articles as $value) {
		?>
		<tr >
			<td><a href="<?php echo site_url('blog/view/'.$value->id);?>"><?php echo $value->title;?></a></td>
			<td><?php echo date("Y-m-d H:i:s",$value->create_time);?></td>
			<td><?php echo $value->view;?></td>
			<td><?php echo $value->recommend==1?'<a class="btn btn-info btn-sm">已推荐</a>':'<a class="btn btn-info btn-sm">未推荐</a>';?></td>
			<td>
			<?php	
			if( $value->recommend==1){
			?>
				<a class="btn btn-warning btn-sm recommend" href="<?php echo site_url('admin/article/article_recommend/'.$value->id) ?>">取消</a>
			<?php }else{ ?>
				<a  class="btn btn-success btn-sm recommend" href="<?php echo site_url('admin/article/article_recommend/'.$value->id) ?>">推荐</a>
			<?php
				}
			?>  
				<a  class="btn btn-primary btn-sm edit" href="<?php echo site_url('admin/article/edit/'.$value->id) ?>">修改</a>
				<a class="del btn btn-danger btn-sm del" href="<?php echo site_url('admin/Article/del/'.$value->id); ?>">删除</a>
			</td>
		</tr>
		<?php
			}
		?>
	</table>
 	<?php echo $this->pagination->create_links(); ?>
</div>
<div id="myModal" class="modal fade">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
         <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body modal-lg">
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
	$(".del").click(function(){
		if(confirm('你确定要删除这条数据吗？')){
			var href=$(this).attr('href');
			$.get(href,function(){
				location.reload();
			});
		}else{
			return false;
		}
	});
	$(function(){
		$(".recommend").click(function(){
			var href=$(this).attr('href');
			$.get(href,function(data,status){
				location.reload();
			});
			return false;
		});
		//编辑时出现小编辑页面
		$('.edit').click(function(){
			var href=$(this).attr('href');
			$.get(href,function(data,status){
				$('.modal-body').html(data);
				$('#myModal').modal('show');
			});
			return false;
		})
		// $('.add').click(function(){
		// 	var href=$(this).attr('href');
		// 	$.get(href,function(data,status){
		// 		$('.modal-body').html(data);
		// 		$('#myModal').modal('show');
		// 	});
		// 	return false;
		// })
	});

</script>
</body>
</html>
